Ext.define('FrontSuite.store.TrackedUrls', {
    extend: 'Ext.data.Store',
    requires: [
        'Ext.data.proxy.Rest'
    ],
    model:  'FrontSuite.model.TrackedUrl',
    autoLoad: true,
    autoSync: true,
    pageSize: 100,
    remoteSort: true,
    requires: [
        'FrontSuite.model.TrackedUrl'
    ],
    proxy : {
        type: 'rest',
        url : 'http://www.acoexhibithall.com/v/prod/apps/sitefront/front-framework/api.php/object/tracked_url',
        reader : {
            type : 'json',
            root : 'data'
        },
        writer: {
            type: 'json',
            writeAllFields: false
        }
    },
    listeners: {
        write: function(store, operation) {
            var record = operation.getRecords()[0];
            var name = Ext.String.capitalize(operation.action);
            var verb;
            if (name == 'Destroy') {
                record = operation.records[0];
                verb = 'Destroyed';
            } else {
                verb = name + 'd';
            }
            Ext.Msg.alert(name + ' Result', Ext.String.format("{0} row: {1}", verb, record.getId()));
        }
    }
});    
